home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
telecomm
/
xprogs.arc
/
ITOA.C
next >
Wrap
Text File
|
1987-11-19
|
406b
|
25 lines
char *itoa(num)
unsigned int num;
{
long digits[6]={1,10,100,1000,10000,100000};
static char str[10];
int max,i;
if (num<2)
{
max=1;
str[0]='0';
}
else
for (max=0;(max<6 && (long) num>digits[max]);str[max++]='0');
str[max]='\0';
if (num>0)
for (i=max;i>=0;--i)
while ((long) num-digits[i]>=0)
{
str[max-1-i]++;
num-=digits[i];
};
return(str);
}